using Microsoft.EntityFrameworkCore;
using Ordering.Infrastructure;

namespace Ordering.API
{
    public static class IHostExtensions
    {
        public static void ApplyMigrations(this IHost host)
        {
            using (var scope = host.Services.CreateScope())
            {
                var context = scope.ServiceProvider.GetRequiredService<OrderingDbContext>();
                context.Database.Migrate();
            }
        }
    }
}